1704. Determine if String Halves Are Alike - LeetCode Solution


String

Python Code:

class Solution:
    def halvesAreAlike(self, s: str) -> bool:

        a, b = 0, 0
        
        for i in range(0, len(s)//2, 1):
            if s[i] in "aeiouAEIOU":
                a+=1

                
                    
        
                
        for i in range( len(s)//2, len(s), 1):
            if s[i] in "aeiouAEIOU":
                b+=1
        
        return a==b


Comments

Submit
0 Comments
More Questions

Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array
580A- Kefa and First Steps
1472B- Fair Division
996A - Hit the Lottery
MSNSADM1 Football
MATCHES Playing with Matches